<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 14-10-29
 * Time: 上午10:32
 */
date_default_timezone_set('Asia/Shanghai');
function makeErrorLog($filename,$errormsg){
    $fp = fopen($filename,'a');
    $str = "Time:".date('Y-m-d H:i')."==Log:".$errormsg."\n";
    fwrite($fp,$str);
    fclose($fp);
}
$datename = 'huer';
$conn = mysql_connect('localhost','root','toor');
if($conn){
    $r =  mysql_select_db($datename,$conn);
    if($r){
        mysql_query('set names utf-8');
    }else{
        makeErrorLog('conn.log',$datename.'mysql datebase is not exist');
    }
}else{
   makeErrorLog('conn.log','mysql database link failure');
}
$sql = "select * from ly_users";
$result = mysql_query($sql);
$arr = mysql_fetch_assoc($result);
if($arr){
    print_r($r);
}else{
    makeErrorLog('conn.log','SQL 语句执行错误');
}